#include "../lib/def.h"

#define DPT_ACTIVE_SIGNATURE 0x80

#define DPT_FAT12 0x01
#define DPT_XENIX_ROOT 0x02
#define DPT_XENIX_USER 0x03
#define DPT_FAT16_BELOW_32MB 0x04
#define DPT_EXTENDED 0x05
#define DPT_FAT16_ABOVE_32MB 0x06
#define DPT_HPFS_NTFS 0x07
#define DPT_AIX 0x08
#define DPT_AIX_BOOTABLE 0x09
#define DPT_OS2_BOOT_MANAGE 0x0A
#define DPT_WINDOWS95_FAT32_1 0x0B
#define DPT_WINDOWS95_FAT32_2 0x0C
#define DPT_WINDOWS95_FAT16 0x0E
#define DPT_WINDOWS95_EXTENDED 0x0F//大于8G
#define DPT_OPUS 0x10
#define DPT_HIDDEN_FAT12 0x11
#define DPT_COMPAQ_DIAGNOST 0x12
#define DPT_HIDDEN_FAT16_SMALL 0x14//小于32MB
#define DPT_HIDDEN_FAT16 0x16
#define DPT_HIDDEN_HPFS_NTFS 0x17
#define DPT_AST_WINDOWS_SWAP 0x18
#define DPT_HIDDEN_FAT32 0x1B
#define DPT_HIDDEN_FAT32_LBA 0x1C
#define DPT_HIDDEN_LBA_VFAT 0x1E
#define DPT_NEC_DOS 0x24
#define DPT_PARTITION_MAGIC 0x3C
#define DPT_VENIX_80286 0x40
#define DPT_PPC_PREP_BOOT 0x41
#define DPT_SFS 0x42
#define DPT_QNX4 0x4D
#define DPT_QNX4_SECOND 0x4E
#define DPT_QNX4_THIRD 0x4F
#define DPT_ONTRACK_DM 0x50
#define DPT_ONTRACK_DM6_AUX_1 0x51
#define DPT_CP_M 0x52
#define DPT_ONTRACK_DM6_AUX_2 0x53
#define DPT_ONTRACK_DM6 0x54
#define DPT_EZ_DRIVE 0x55
#define DPT_GOLDEN_BOW 0x56
#define DPT_PRIAM_EDISK 0x5C
#define DPT_SPEED_STOR 0x61
#define DPT_GNU_HURD_OR_SYS 0x63
#define DPT_NOVELL_NETWARE1 0x64
#define DPT_NOVELL_NETWARE2 0x65
#define DPT_DISK_SECURE_MULT 0x70
#define DPT_PC_IX 0x75
#define DPT_OLD_MINIX 0x80
#define DPT_MINIX_OLD_LINUX 0x81
#define DPT_LINUX_SWAP 0x82
#define DPT_LINUX 0x83
#define DPT_OS2_HIDDEN_C 0x84
#define DPT_LINUX_EXTENDED 0x85
#define DPT_NTFS_VOLUME_SET_1 0x86
#define DPT_NTFS_VOLUME_SET_2 0x87
#define DPT_AMOEBA 0x93
#define DPT_AMOEBA_BBT 0x94
#define DPT_IBM_THINKPAD_HIDDEN 0xA0
#define DPT_BSD_386 0xA5
#define DPT_OPEN_BSD 0xA6
#define DPT_NEXT_STEP 0xA7
#define DPT_BSDI_FS 0xB7
#define DPT_BSDI_SWAP 0xB8
#define DPT_SOLARIS_BOOT_PARTITION 0xBE
#define DPT_DRDOS_NOVELL_SECURED_PARTITION 0xC0
#define DPT_DRDOS_SEC_1 0xC1
#define DPT_DRDOS_SEC_2 0xC4
#define DPT_DRDOS_SEC_3 0xC6
#define DPT_SYRINX 0xC7
#define DPT_CP_M_CTOS 0xDB
#define DPT_DOS_ACCESS 0xE1
#define DPT_DOS_R0 0xE3
#define DPT_SPEEDSTOR_1 0xE4
#define DPT_BEOS_FS 0xEB
#define DPT_SPEEDSTOR_2 0xF1
#define DPT_DOS3_3PLUS_SECONDARY_PARTITION 0xF2
#define DPT_SPEEDSTOR_3 0xF4
#define DPT_LAN_STEP 0xFE
#define DPT_BBT 0xFF

typedef struct {
    BYTE bActiveSignature;
    BYTE bStartHead;
    WORD wStartSector : 6;
    WORD wStartCylinderLow : 10;
    BYTE bType;
    BYTE bEndHead;
    WORD wEndSector : 6;
    WORD wStartCylinderHigh : 10;
    DWORD dwAbsoluteStartSector;
    DWORD dwTotalSector;
} DPT_DESC, *PDPT_DESC;

typedef struct {
    CHAR Signature[8];
    DWORD dwVersion;
    DWORD dwTotalBytes;
    DWORD dwGPTHeaderCrc;
    DWORD dwReserved;
    QWORD qwGPTHeaderSector;
    QWORD qwGPTHeaderCopy;
    QWORD qwStartSector;
    QWORD qwEndSector;
    GUID DiskID;
    QWORD qwGPTTableSector;
    DWORD dwPartitionCount;
    DWORD dwGPTTableBytesCount;
    DWORD dwGPTTableCrc;
    BYTE bReserved[420];
} GDT_HEADER_DESC, *PGDT_HEADER_DESC;

//16 E3 C9 E3 5C 0B B8 4D 81 7D F9 2D F0 02 15 AE
EXTERN GUID GPT_TYPE_MSR;
//AA C8 08 58 8F 7E E0 42 85 D2 E1 E9 04 34 CF B3
EXTERN GUID GPT_LDM_ORIGIN_DATA;
//A0 60 9B AF 31 14 62 4F BC 68 33 11 71 4A 69 AD
EXTERN GUID GPT_LDM_DATA;
//00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00	
EXTERN GUID GPT_TYPE_NONE;
//C1 2A 73 28 F8 1F 11 D2 BA 4B 00 A0 C9 3E C9 3B
EXTERN GUID GPT_TYPE_EFI_SYSTEM;
//02 4D EE 41 33 E7 11 d3 9D 69 00 08 C7 81 F3 9F
EXTERN GUID GPT_TYPE_DOS_PARTITION;
//A2 A0 D0 EB E5 B9 33 44 87 C0 68 B6 B7 26 99 C7
EXTERN GUID GPT_TYPE_BASIC_DATA;

typedef struct {
    GUID TypeID;
    GUID PartitionID;
    QWORD qwStart;
    QWORD qwEnd;
    QWORD qwAttributes;
    CHAR16 szName[36];
} GPT_PART_DESC, *PGPT_PART_DESC;